using Clancy.Data;
using Clancy.Interfaces;
using Clancy.Service.Client.LiveStreamFeedbackTcpClient;

namespace Clancy.Service.Client
{
    public class LiveFeedbackCallbackservice : ILiveStreamInterfaceCallback
    {
        private readonly IOnlineOperationAdapter m_OperationsAdapter;

        public LiveFeedbackCallbackservice(IOperationAdapter operationsAdapter)
        {
            m_OperationsAdapter = operationsAdapter as IOnlineOperationAdapter;
        }

        public void ReturnCurrentRecordings(RecordingItem[] surveilanceObjects)
        {
            m_OperationsAdapter.RecordingCollection.Clear();
            ReturnRecoridngsAdded(surveilanceObjects);
        }

        public void ReturnRecoridngsAdded(RecordingItem[] recordingItems)
        {
            foreach (RecordingItem recording in recordingItems)
            {
                m_OperationsAdapter.RecordingCollection.Add(recording);
            }
        }

        public void ReturnRecoridngsRemoved(RecordingItem[] recordingItems)
        {
            foreach (RecordingItem recording in recordingItems)
            {
                m_OperationsAdapter.RecordingCollection.Remove(recording);
            }
        }

        public void ReturnSurveilanceResultFrame(SurveilanceObject surveilanceObject, SurveilanceResultFrame resultFrame)
        {
            m_OperationsAdapter.SetResultFrame(surveilanceObject, resultFrame);
        }
    }
}